open(BUFF,"final.tfam");
open(WRBUFF,">combined_GBM_normal_plink_final.tped");
$n =0;
while(<BUFF>)
{
	chomp($_);
	@a = split(" ",$_);
	@array1 = split('-',$a[1]);
	$arr[$n] = "$array1[0]-$array1[1]-$array1[2]";;	
	$n++;
}
$line = join(" ",@arr);
print WRBUFF $line."\n";
open(BUFF,"final.dosage");
open(BUFF1,"final.map");
while($l1=<BUFF>)
{
	chomp($l1);
	$l2 = <BUFF1>;
	chomp($l2);
	$line = $l2." ".$l1;
	@a = split(" ",$line);
	print WRBUFF "$a[0] $a[1] $a[2] $a[3] $a[4] $a[5] $a[6]";
	for($i=7;$i<@a;$i++)
	{
		$val1 = $a[$i];
		$i++;
		$val2 = $a[$i];
		$val = $val2+(2*(1-$val1-$val2));
		print WRBUFF " $val";
	}
	print WRBUFF "\n";
}
close(WRBUFF);
=head
open(BUFF,"temp");
open(WRBUFF,">combined_GBM_normal_plink_final.tped");
$line=<BUFF>;
@array=split(" ",$line);
$nu =0;
for($i=0;$i<@array;$i++)
{
	@array1 = split('-',$array[$i]);
        #print $array1[3]."\n";
        @array2 = split(//,$array1[3]);
        $l = $array2[0].$array2[1];
        #print $l."\n";
        #if($l eq "01")
        #{
                #print WRBUFF1 $line."\n";
                #system("mv ./expr/$line ./GBM_expr_tumor");
                #system("mv ./OV_expr/$line ./OV_expr_tumor");
        #}
        #elsif($l eq "10" || $l eq "11" || $l eq "12")
        if($l eq "10" || $l eq "11" || $l eq "12")
	{
                #print WRBUFF2 $line."\n";
                #system("mv ./expr/$line ./GBM_expr_normal");
                #system("mv ./OV_expr/$line ./OV_expr_normal");
        	$verify[$i] = 1;
		$samplenames[$nu] = "$array1[0]-$array1[1]-$array1[2]";
		$nu++;
	}
        else
        {
		$verify[$i] = 0;
        }
	
}
$line = join(" ",@samplenames);
print $line."\n";
